﻿using Curry.Forum.Facade;
using Curry.Forum.Facade.Enum;
using Curry.Forum.Query.Service;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Curry.Forum.Query.Command
{
    public class HomeCommand
    {
        private IHomeQueryService _homeQueryService;
        public HomeCommand(IHomeQueryService homeQueryService)
        {
            _homeQueryService = homeQueryService;
        }

        public BasicResponse Login(string name, string pwd)
        {
            BasicResponse response = new BasicResponse();
            try
            {
                object data = _homeQueryService.Login(name, pwd);
                if (data != null)
                    response.PostData = data;
                else
                {
                    response.RtnCode = (int)ReturnedCodeEnum.登录失败;
                    response.ErrorMsg = ReturnedCodeEnum.登录失败.ToString();
                }
            }
            catch (Exception ex)
            {
                response.RtnCode = (int)ReturnedCodeEnum.登录失败;
                response.ErrorMsg = ex.Message;
            }
            return response;
        }
    }
}
